/**
 * Created by Julia on 2016/5/06.
 */
require(['business/permission/permissionBiz'], function (permission) {
    //pageSetUp();
    permission.init();
    $('table a.deleteRole').unbind('click').click(function (e) {
        permission.btnStyleEvent($this.closest('tr').next('tr.edit').find('.addRole_Re'));
        var roleId = $(this).attr('roleId');
        var permissionCode = $(this).attr('permissionCode');
        var permissionId = $(this).closest("td").next("td.havRole").find('.btnRole').attr('permissionId');
        permission.deleteRoleConfirm(permissionId, roleId, permissionCode);
    });

    $('table a.btnRole').unbind('click').click(function (e) {
        var $this = $(this);
        var edit = $(this).closest('tr').next('tr.edit');
        if (edit.size() > 0) {
            return false;
        }
        var tr = $('#tb_edit > tbody');
        $(this).closest('tr').after(tr.html());
        var resourceId = $(this).attr("permissionId");
        var permissionCode = $(this).attr('permissionCode');
        permission.showCanAddRole(resourceId, permissionCode, function (d) {
            var td = permission.format(d, resourceId, permissionCode);
            //$this.closest('tr').next('tr.edit').html(td);
            permission.setHtml($this.closest('tr').next('tr.edit'), td, function () {
                permission.initPermissionEvent();
            });

        });
    });
});